<template>
  <div class="result">
    <p>
      <span style="margin-right: 5px">[{{ result.type }}]</span>{{ result.title.split("###")[0] }}
    </p>
    <div v-if="result.type == '选择题'" class="options">
      <p v-for="(item, index) in result.title.split('###')[1].split('#')" :key="index">
        <span>{{ String.fromCharCode(65 + index) + "." }}</span>
        {{ item }}
      </p>
    </div>
    <div class="key">
      <span style="color: red">正确答案：</span>
      <div v-if="result.type == '选择题'">
        <p v-for="(item, index) in result.answer.split('#')" :key="index">
          {{ item }}
        </p>
      </div>
      <div v-else-if="result.type == '判断题'">
        <p>{{ result.answer }}</p>
      </div>
      <div v-else-if="result.type == '填空题'">
        <p>{{ result.answer }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["result"],
};
</script>

<style lang="scss">
.result {
  margin: 0 auto;
  border-bottom: 1px solid #eee;
  ul > li {
    list-style: none;
  }
  p {
    word-wrap: break-word;
    word-break: break-all;
    overflow: hidden;
  }
  .options {
    span {
      margin-right: 5px;
    }
  }
}
@media screen and (max-width: 768px) {
  .result {
    width: 80%;
  }
}
@media screen and (min-width: 992px) {
  .result {
    width: 700px;
  }
}
</style>
